//
//  UIActionSheetViewController.m
//  UITest
//
//  Created by wp w on 12-6-7.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "UIActionSheetViewController.h"

@interface UIActionSheetViewController ()

@end

@implementation UIActionSheetViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad {
	
	[super viewDidLoad];
	
	UIActionSheet *mySheet = [[UIActionSheet alloc] initWithTitle:@"Email Deletion Options" 
														 delegate:self 
												cancelButtonTitle:@"Cancel" 
										   destructiveButtonTitle:@"Delete Everything" 
												otherButtonTitles:@"All Read Email", @"Spam Only",nil];
	
	
	mySheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
	[mySheet showInView:self.view];	
	
	[mySheet release];
}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
	//destructiveButtonTitle索引为0
    //cancelButtonTitle索引为最后
	BOOL cancelClicked = actionSheet.cancelButtonIndex == buttonIndex;
	BOOL destructiveButtonClicked = actionSheet.destructiveButtonIndex == buttonIndex;
	
	NSLog(@"button with index %i clicked (cancel:%i, destructive:%i)",buttonIndex,cancelClicked,destructiveButtonClicked);
	
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
